#include "SGPCLEuclideanCluster.h"

namespace sgpcl
{

SGEuclideanClusterConfig::SGEuclideanClusterConfig()
  : nMinClusterSize(0)
  , fClusterTolerance(0.f)
{
}

void SGEuclideanClusterConfig::ParseJson(const rapidjson::Value& sJsonRoot) {

  SGPCLJsonConfig::ParseJson(sJsonRoot, "欧式距离聚类");

  // 欧式聚类最小簇尺寸
  rapidjson::Value::ConstMemberIterator itMember = sJsonRoot.FindMember("MinClusterSize");
  if (itMember != sJsonRoot.MemberEnd())
  {
    nMinClusterSize = itMember->value.GetInt();
  }
  else
  {
    SG_LOG("未指定\"欧式聚类最小簇尺寸\"，采用默认值\"" + std::to_string(nMinClusterSize) + "\"");
  }

  // 欧式聚类生长距离
  itMember = sJsonRoot.FindMember("ClusterTolerance");
  if (itMember != sJsonRoot.MemberEnd())
  {
    fClusterTolerance = itMember->value.GetFloat();
  }
  else
  {
    SG_LOG("未指定\"欧式聚类生长距离\"，采用默认值\"" + std::to_string(fClusterTolerance) + "\"");
  }
}
}
